﻿/******************************************************************************
* File description: UdpClient.cpp
* Function: UDP通信线程
* Current Version: 1.0.0
* Author: 郑佰旺
* Date: 2025-07-1
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/

#include "UdpClient.h"

extern int npwhfl;
UdpClient* UdpClient::Instance=0;

UdpClient* UdpClient::getInstance()
{
    if(Instance==0)
        Instance =new UdpClient();
    return Instance;
}

UdpClient::UdpClient(QObject *parent): QUdpSocket(parent)
{
    connect(this, &UdpClient::SignalConnectToHost, this, [&](const QString & address, quint16 port) {
        this->abort();
        this->bind(8080);
        this->connectToHost(QHostAddress(address), port, QIODevice::ReadWrite);
    }, Qt::AutoConnection);

    //执行数据发送过程
    QObject::connect(this, &UdpClient::SignalSendingData, this, [&](const QByteArray c_btaData)
    {
        backSendData=c_btaData;
        this->write(c_btaData);

        QString str;
        for(int c :c_btaData)
        {
            if(c>=0)
            {
                str += QString(" %1").arg(c, 2, 16, QChar('0')).toUpper();
            }
            else
            {
                str += QString(" %1").arg(c+256, 2, 16, QChar('0')).toUpper();
            }
        }
        str= str.simplified();
        QStringList list=str.split(" ");
        saveLog("发送",list);

        if(StaticProperties::expStatus==1)
        {
            isSyring=list[7]=="01";
            receiveSuccess=false;
        }
        QTimer::singleShot(4000, [this]() {
            if(!StaticProperties::heartMsg)
                m_bOnLine=false;
        });
    }, Qt::AutoConnection);

    //收到了UDP服务的数据
    QObject::connect(this, &QIODevice::readyRead, this, [&]() {
        QByteArray arr = this->readAll();
        QString str;
        for(int c :arr)
        {
            if(c>=0)
            {
                str += QString(" %1").arg(c, 2, 16, QChar('0')).toUpper();
            }
            else
            {
                str += QString(" %1").arg(c+256, 2, 16, QChar('0')).toUpper();
            }
        }
        str= str.simplified();

        if(str.length()>10)
        {
            if(!StaticProperties::isForcedStop){
                QStringList list=str.split(" ");
                while (list.length()>6) {
                    int dataLength=CommonHelper::Common().SixteenToTen(list[5]).toInt()+6;
                    QStringList partList=list.mid(0, dataLength);
                    receiveDataProcessing(partList);
                    list=list.mid(dataLength);
                }
                QMLSignal::I().emitRefCommunicationLog();
            }
            else{
                StaticProperties::isForcedStop=false;
            }
        }
    }, Qt::DirectConnection);
}

//
UdpClient::~UdpClient()
{

}

//跨线程转换
void UdpClient::ClientConnectToHost(const QString & address, quint16 port)
{
    emit SignalConnectToHost(address, port);
}

//跨线程转换
void UdpClient::ClientSendingData(const QByteArray & c_btaData)
{
    emit SignalSendingData(c_btaData);
}

/**
 * @brief UdpClient::receiveDataProcessing 处理接收到的下位机数据
 * @param list 下位机接收数据
 */
void UdpClient::receiveDataProcessing(QStringList list){
    if(list.length()>10)
    {
        saveLog("接收",list);
        if(list[0]=="62"&& list[1]=="00" && list[2]=="00" &&list[3]=="3A")
        {
            if(list[6]=="00" && list[7]=="02")//网络连接
            {
                StaticProperties::heartMsg=true;
                m_bOnLine=true;
                QMLSignal::I().emitCommunicationStatus(0);     // 发信号通知前端
                if(StaticProperties::firstConnect){
                    SignalSendingData(CommonHelper::Common().GetSendData(CommCommand::I().getMachineStatus()));
                    SignalSendingData(CommonHelper::Common().GetSendData(CommCommand::I().getResetStatus()));
                    StaticProperties::firstConnect=false;

                    CpsUdpClient *cpsClient=CpsUdpClient::getInstance();
                    cpsClient->ClientSendingData(CommonHelper::Common().GetSendData(CommCommand::I().readRadiation("01")));

                    if(!StaticProperties::existSoft){
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);

                        QString  sql="Select case When (Select expStep From ExperimentInfo) <=(Select max(key) From ExperimentDetail) then 0 else 1 end as result";
                        query.exec(sql);
                        bool existExp=false;
                        while (query.next()) {
                            existExp=query.value("result").toInt()==0;
                        }
                        if(existExp){
                            sql="Select * From ReportDetail Where ReportSerial=(Select max(ReportSerial) From ReportDetail) and Status='进行中'";
                            query.exec(sql);
                            int module;
                            int step;
                            QString actionInfo;
                            while (query.next())
                            {
                                module=query.value("Module").toInt();
                                step=query.value("Step").toInt();
                                actionInfo=query.value("ActionInfo").toString();
                            }
                            int nextModule;
                            int nextStep=-1;
                            QString nextActionInfo;

                            sql=QString("Select * From ReportDetail Where ReportSerial=(Select max(ReportSerial) From ReportDetail) and Step='%1'").arg(QString::number(step+1));
                            query.exec(sql);

                            while (query.next())
                            {
                                nextModule=query.value("Module").toInt();
                                nextStep=query.value("Step").toString().isNull()?-1:query.value("Step").toInt();
                                nextActionInfo=query.value("ActionInfo").toString();
                            }
                            StaticProperties::continueModule[0]=module;
                            StaticProperties::continueModule[1]=nextModule;
                            emit QMLSignal::I().emitSendExistExp(module,step,actionInfo,nextModule,nextStep,nextActionInfo);
                            //                        QMLSignal::I().emitSendErrorMsg("故障:软件异常退出","是","0");
                        }
                    }
                    StaticProperties::existSoft=true;
                }
            }
            else if(list[6]=="01")//启动实验
            {
                if(npwhfl==0){
                    if(list[7]=="01"){
                        emit QMLSignal::I().experimentStatus(1,0,"");
                    }
                    else if(list[7]=="02")
                    {
                        StaticProperties::isConcurrency=false;
                        StaticProperties::productSyringStep=0;
                        StaticProperties::expStep = StaticProperties::expStartStep;
                        StaticProperties::currentStep = StaticProperties::expStartStep;
                        StaticProperties::concurrencyStepMap.clear();
                        StaticProperties::expStatus=1;
                        StaticProperties::expUnionStep=1;
                        StaticProperties::isWaitStep=false;
                        QMLSignal::I().experimentStatus(1,1,"");
                        ExperimentThread::I().run();
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);

                        QString sql=QString("Update ModuleResetStatus set Status=0");
                        query.exec(sql);
                    }
                }
            }
            else if(list[6]=="02")//暂停
            {
                if(list[7]=="01"){
                    QMLSignal::I().experimentStatus(3,0,"");
                }
                else if(list[7]=="02")
                {
                    QMLSignal::I().experimentStatus(3,1,"");
                }
            }
            else if(list[6]=="03")//继续
            {
                if(list[7]=="01"){
                    emit  QMLSignal::I().experimentStatus(4,0,"");
                }
                else if(list[7]=="02")
                {
                    if(!StaticProperties::isWait && StaticProperties::finishInPause){
                        StaticProperties::finishInPause=false;
                        ExperimentThread::I().run();
                    }
                    emit QMLSignal::I().experimentStatus(4,1,"");
                }
            }
            else if(list[6]=="04")//停止
            {
                if(npwhfl==0){
                    if(list[7]=="01"){
                        emit QMLSignal::I().experimentStatus(2,0,"");
                    }
                    else if(list[7]=="02"){
                        StaticProperties::runningList.clear();
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);
                        QDateTime current=QDateTime::currentDateTime();
                        QString dateStr=current.toString("yyyy-MM-dd");
                        StaticProperties::isWaitStep=false;
                        StaticProperties::expStatus=0;
                        StaticProperties::currentStep=0;
                        StaticProperties::isConcurrency=false;

                        saveReportInfo();
                        QString sql=QString("Update DataStatistics Set RubberPad=RubberPad+1 Where StaticDate='%1'").arg(dateStr);
                        query.exec(sql);
                        sql="Delete From ExperimentDetail";
                        query.exec(sql);
                        sql="Delete From ExperimentInfo";
                        query.exec(sql);

                        exportCpsData();
                        QMLSignal::I().experimentStatus(2,1,"");

                        sql=QString("Update ModuleResetStatus set Status=0");
                        query.exec(sql);
                    }
                }
            }
            else if(list[6]=="05"){
                analyzeDetectionInformation(list);
            }
            else if(list[6]=="07"){
                if(StaticProperties::softType!=1)//包含纯化
                {
                    for(int i=7;i<13;i++){
                        if(list[i]!="02"){
                            QMLSignal::I().emitNeedReset();
                            break;
                        }
                    }

                    QSqlDatabase db = dbHelper::openConnection();
                    QSqlQuery query(db);
                    QString sql="Select IsUsed From ComponentInfo Where serial='8' and Module=4 ";//蠕动泵
                    query.exec(sql);
                    int isUsed=0;
                    while (query.next()) {
                        isUsed=query.value("IsUsed").toInt();
                    }
                    if(isUsed==1)//启用蠕动泵
                    {
                        if(list[14]!="02")
                        {
                            QMLSignal::I().emitNeedReset();
                            return;
                        }
                    }
                    else//启动转盘
                    {
                        if(list[13]!="02"){
                            QMLSignal::I().emitNeedReset();
                            return;
                        }
                    }
                }

                if(StaticProperties::softType!=2 && list[15]!="02")//打靶模块
                {
                    QMLSignal::I().emitNeedReset();
                    return;
                }

            }
            else if(list[6]=="08")//瓶子状态
            {
                if(list[8]=="02"){
                    QSqlDatabase db = dbHelper::openConnection();
                    QSqlQuery query(db);
                    QString expName;
                    if(StaticProperties::currentExpType==0){
                        expName=QString("value_1=(Select PurifyingExp From MainExperimentalProcess Where ExperimentName='%1')").arg(StaticProperties::currentExpName);
                    }
                    else{
                        expName=QString("value_1='%1'").arg(StaticProperties::currentExpName);
                    }
                    QString sql=QString("Select distinct value_1 From exe_config "
                                        "Where id=(Select id From exe_config Where type=0 and %1) and type=3").arg(expName);

                    query.exec(sql);
                    QStringList posList;
                    while (query.next()) {
                        QString info=query.value("value_1").toString();
                        if(info.contains("接液位置")){
                            posList.append(query.value("value_1").toString().remove("接液位置"));
                        }
                    }
                    QStringList realPos;
                    int length=CommonHelper::Common().SixteenToTen(list[5]).toInt()-7;
                    int num=0;
                    for(int i=0;i<length;i++){
                        realPos.append(list[i+9]);
                        if(list[i+9]=="01"){
                            num++;
                        }
                    }


                    for(int i=0;i<posList.length();i++){
                        if(realPos[posList[i].toInt()-1]!="01"){
                            emit QMLSignal::I().experimentStatus(1,2,"转盘中,瓶子摆放位置不符合实验配置中设置的位置,请检查确认后再启动实验");
                            return;
                        }
                    }
                    ClientSendingData(CommonHelper::Common().GetSendData( CommCommand::I().startExperiment()));
                    ExpCommonMethod::Common().saveExpInfo();

                }
            }
            else if(list[6]=="0A")
            {
                if(list[7]=="00"&& list[8]=="01"){
                    QMLSignal::I().emitSendResetMsg("1",0);
                }
                if(list[7]!="00" && list[9]=="02")
                {
                    int pos= list[7].toInt();
                    if(pos==20)
                    {
                        QMLSignal::I().emitSendResetMsg("0",10);
                        QMLSignal::I().emitSendResetMsg("0",11);
                    }
                    else{
                        QMLSignal::I().emitSendResetMsg("0",pos);
                    }
                }
            }
        }
        else if(list[0]=="62"&& list[1]=="00" && list[2]=="00" && list[3]=="3B")//实验指令
        {
            if(StaticProperties::expStatus==1){
                if(list[7]=="02")//步骤完成
                {
                    int currentStep=CommonHelper::Common().SixteenToTen(list[6]).toInt();
                    if(StaticProperties:: isConcurrency && currentStep==1)
                    {
                        StaticProperties::expUnionStep++;
                        ExperimentThread::I().concurrencyUnionRun();
                    }
                    if(list[6]=="00" || (currentStep!=StaticProperties::productSyringStep && currentStep<StaticProperties::expStep ))
                    {
                        return;
                    }
                    if(StaticProperties::productSyringStep==currentStep)
                    {
                        qint64 msecs = QDateTime::currentDateTime().toMSecsSinceEpoch() - StaticProperties::productSyringStartTime.toMSecsSinceEpoch();

                        StaticProperties::expLogList[3][StaticProperties::productSyringStep]["Status"]="完成";
                        StaticProperties::expLogList[3][StaticProperties::productSyringStep]["FinishTime"]=CommonHelper::Common().GetTimeStr();
                        StaticProperties::expLogList[3][StaticProperties::productSyringStep]["Time"]=QString::number(msecs);

                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);
                        QString sql=QString("Update ReportDetail set status='完成',FinishTime='%1',Time='%2' Where ReportSerial=(Select max(ReportSerial) From ReportDetail) and Step='%3'").arg(CommonHelper::Common().GetTimeStr(),QString::number(msecs),QString::number(StaticProperties::productSyringStep));
                        query.exec(sql);
                        QMLSignal::I().emitRefExperimentLog(StaticProperties::currentStep);
                    }
                    else
                    {
                        AnimationParseHEX::I().parse(list,1);
                        StaticProperties::expStep=CommonHelper::Common().SixteenToTen(list[6]).toInt()+1;
                        ExperimentThread::I().run();
                    }
                }
                else if(list[7]=="01")//确认收到信息(主要是为了发送给jnn操作前端动画)
                {
                    if(CommonHelper::Common().SixteenToTen(list[6])!="00")
                    {
                        if(StaticProperties::expRecovery){
                            StaticProperties::expRecovery=false;
                            QMLSignal::I().experimentStatus(1,1,"");
                        }
                        int nowStep=CommonHelper::Common().SixteenToTen(list[6]).toInt();
                        QVariantMap map= StaticProperties::expSendList[nowStep];
                        AnimationParseHEX::I().parse(map["Info"].toString().toUpper().split(" "),0);
                    }
                }
                else //故障
                {
                    faultAnalysisAndHandling(list,7);
                }
            }
            else if(StaticProperties::expStatus==2)
            {
                if(list[7]=="02")//步骤完成
                {
                    int currentStep=CommonHelper::Common().SixteenToTen(list[6]).toInt();

                    if(StaticProperties:: isConcurrency && currentStep==1)
                    {
                        StaticProperties::expUnionStep++;
                        ExperimentThread::I().concurrencyUnionRun();
                    }
                    if(list[6]=="00" ||  currentStep<StaticProperties::expStep)
                    {
                        return;
                    }
                    if(StaticProperties::productSyringStep==currentStep)
                    {
                        qint64 msecs = QDateTime::currentDateTime().toMSecsSinceEpoch() - StaticProperties::productSyringStartTime.toMSecsSinceEpoch();

                        StaticProperties::expLogList[3][StaticProperties::productSyringStep]["Status"]="完成";
                        StaticProperties::expLogList[3][StaticProperties::productSyringStep]["FinishTime"]=CommonHelper::Common().GetDateTimeStr();
                        StaticProperties::expLogList[3][StaticProperties::productSyringStep]["Time"]=QString::number(msecs);

                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);
                        QString sql=QString("Update ReportDetail set status='完成',FinishTime='%1',Time='%2' Where ReportSerial=(Select max(ReportSerial) From ReportDetail) and Step='%3'").arg(CommonHelper::Common().GetTimeStr(),QString::number(msecs),QString::number(StaticProperties::productSyringStep));
                        query.exec(sql);
                        QMLSignal::I().emitRefExperimentLog(StaticProperties::currentStep);
                    }
                    else
                    {
                        StaticProperties::finishInPause=true;
                        StaticProperties::expStep=CommonHelper::Common().SixteenToTen(list[6]).toInt()+1;
                    }
                }
            }
            else if(StaticProperties::expStatus==0)
            {
                if(list[7]=="02")//执行完成
                {
                    QString pos= CommonHelper::Common().SixteenToTen(list[6]);
                    if(StaticProperties::runningList.contains(pos)){
                        StaticProperties::  runningList.removeOne(pos);
                        QMLSignal::I().emitSendSyringRunMsg("0",pos);
                    }
                    QMLSignal::I().emitStepRunningStatus(2);
                }
                else if(list[7]=="01"){
                    QMLSignal::I().emitStepRunningStatus(1);
                }
                else //故障
                {
                    faultAnalysisAndHandling(list,7);
                }
            }
        }
        else if(list[0]=="62" && list[1]=="00" && list[2]=="00" && list[3]=="3C")//维护指令
        {
            if(list[6]=="02")//设置压力
            {
                if(list[7]=="02" && list[9]=="02"){
                    QString open=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                    QString close=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]);
                    QMLSignal::I().emitSendAirPumpPressure(open,close);
                }
            }
            else if(list[6]=="04")//电机复位到实验位置
            {
                QString pos= CommonHelper::Common().SixteenToTen(list[7]);
                if(pos.toInt()==0){
                    pos="8";
                }
                if(list[9]=="01")
                {
                    QMLSignal::I().emitSendResetMsg("1",pos.toInt());
                }
                else if(list[9]=="02")
                {
                    QMLSignal::I().emitSendResetMsg("0",pos.toInt());
                    if(!resetPosList.contains(pos.toInt())){
                        resetPosList.append(pos.toInt());
                    }
                    if(resetPosList.length()>=6){
                        resetPosList.clear();
                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);

                        QString sql=QString("Update ModuleResetStatus set Status=1 Where module=4");
                        query.exec(sql);
                    }
                }
            }
            else if(list[6]=="05")//电机复位到光耦位置
            {
                QString pos= CommonHelper::Common().SixteenToTen(list[7]);
                if(pos.toInt()==0){
                    pos="8";
                }
                if(list[9]=="01"){
                    QMLSignal::I().emitSendResetMsg("1",pos.toInt());
                }
                else if(list[9]=="02")
                {
                    QMLSignal::I().emitSendResetMsg("0",pos.toInt());
                }
            }
            else if(list[6]=="06")//注射器运动
            {
                QString pos= CommonHelper::Common().SixteenToTen(list[7]);

                if(list[9]=="01"){
                    QMLSignal::I().emitSendSyringRunMsg("1",pos);
                }
                else if(list[9]=="02"){
                    QMLSignal::I().emitSendSyringRunMsg("0",pos);
                }
            }
            else if(list[6]=="08")//转盘读取
            {
                if(list[8]=="02"){
                    QString steps=CommonHelper::Common().SixteenToTen(list[9]+" "+list[10]+" "+list[11]+" "+list[12]);
                    QMLSignal::I().emitSendTurnTablePos(steps);
                }
            }
            else if(list[6]=="0C")//点击停止运动
            {
                if(list[8]=="02"){
                    QString pos= CommonHelper::Common().SixteenToTen(list[7]);
                    StaticProperties::runningList.removeOne(pos);
                }
            }
            else if(list[6]=="12" && list[9]=="02")//电机参数配置读取
            {
                QString steps1=CommonHelper::Common().SixteenToTen(list[10]);
                QString steps2=CommonHelper::Common().SixteenToTen(list[11]);
                QString steps3=CommonHelper::Common().SixteenToTen(list[12]);
                QMLSignal::I().emitchDJCS(steps1,steps2,steps3);
            }
            else if(list[6]=="13" && list[9]=="02")//电机最大行程读取
            {
                QString steps1=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]+" "+list[12]+" "+list[13]);
                QMLSignal::I().emitchDJMAX(steps1);
            }
            else if(list[6]=="30")//转靶放靶气泵维护
            {
                QString steps=CommonHelper::Common().SixteenToTen(list[8]+" "+list[9]);
                QMLSignal::I().emitSendTargetAirPumpPressure(steps);
            }
            else if(list[6]=="51" && list[9]=="02")//放靶空气及气压维护
            {
                QString steps=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QMLSignal::I().emitfbGetAir(steps);
            }
            else if(list[6]=="6E" && list[9]=="02")//打靶传感器数量
            {
                QString steps=CommonHelper::Common().SixteenToTen(list[10]);
                QMLSignal::I().emitdbcgqsl(steps);
            }
            else if(list[6]=="6F" && list[9]=="02")//打靶氦气气压维护
            {
                QString steps=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QMLSignal::I().emitdblsjyl(steps);
            }
            else if(list[6]=="71" && list[9]=="02")//打靶氦气气压维护
            {
                QString steps=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QMLSignal::I().emitdbhqGetAir(steps);
            }
            else if(list[6]=="72" && list[9]=="02")//打靶吸取靶气压维护
            {
                QString steps=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QMLSignal::I().emitdbxqbGetAir(steps);
            }
            else if(list[6]=="85" && list[8]=="01")//打靶干燥维护
            {
                QMLSignal::I().emitdbGzwh();
            }
            else if(list[6]=="24" && list[9]=="02")//打靶吸取靶气压维护
            {
                QString steps=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QString steps2=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]);
                QMLSignal::I().emitzbxpGetAir(steps,steps2);
            }
            else if(list[6]=="25" &&list[9]=="02")//Z轴电机位置
            {
                QString steps2=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QString steps=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]+" "+list[14]+" "+list[15]);
                QMLSignal::I().emitzbZZ(steps2,steps);
            }
            else if(list[6]=="26" &&list[9]=="02")//X轴电机位置
            {
                QString steps2=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QString steps=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]+" "+list[14]+" "+list[15]);
                QMLSignal::I().emitzbXZ(steps2,steps);
            }
            else if(list[6]=="27" && list[9]=="02")//开盖电机位置
            {
                QString steps2=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QString steps=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]+" "+list[14]+" "+list[15]);
                QMLSignal::I().emitzbKG(steps2,steps);
            }
            else if(list[6]=="2D" && list[9]=="02")//活性电机位置
            {
                QString steps2=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QString steps=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]+" "+list[14]+" "+list[15]);
                QMLSignal::I().emitzbHX(steps2,steps);
            }
            else if(list[6]=="2E" && list[9]=="02")//吸盘电机位置
            {
                QString steps2=CommonHelper::Common().SixteenToTen(list[10]+" "+list[11]);
                QString steps=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]+" "+list[14]+" "+list[15]);
                QMLSignal::I().emitzbXPDJ(steps2,steps);
            }
            else if(list[6]=="70")
            {
                if(list[8]=="01")
                {
                    QMLSignal::I().emitSendResetMsg("1",11);
                }
                else if(list[8]=="02")
                {
                    QMLSignal::I().emitSendResetMsg("0",11);
                    QSqlDatabase db = dbHelper::openConnection();
                    QSqlQuery query(db);

                    QString sql=QString("Update ModuleResetStatus set Status=1 Where module=2");
                    query.exec(sql);
                }
                else {
                    faultAnalysisAndHandling(list,8);
                }
            }
            else if(list[6]=="50")
            {
                if(list[8]=="01")
                {
                    QMLSignal::I().emitSendResetMsg("1",10);
                }
                else if(list[8]=="02")
                {
                    QMLSignal::I().emitSendResetMsg("0",10);
                    QSqlDatabase db = dbHelper::openConnection();
                    QSqlQuery query(db);

                    QString sql=QString("Update ModuleResetStatus set Status=1 Where module=1");
                    query.exec(sql);
                }
                else{
                    faultAnalysisAndHandling(list,8);
                }
            }
            else if(list[6]=="0E"){
                QString pos= CommonHelper::Common().SixteenToTen(list[7]);
                if(list[9]=="01"){
                    if(list[8]=="20"){
                        QMLSignal::I().emitSendResetMsg("1",10);
                        QMLSignal::I().emitSendResetMsg("1",11);
                    }else{
                        QMLSignal::I().emitSendResetMsg("1",pos.toInt());
                    }
                }
                else if(list[9]=="02")
                {
                    if(list[8]=="20"){
                        QMLSignal::I().emitSendResetMsg("0",10);
                        QMLSignal::I().emitSendResetMsg("0",11);

                        QSqlDatabase db = dbHelper::openConnection();
                        QSqlQuery query(db);

                        QString sql=QString("Update ModuleResetStatus set Status=1 Where module=1");
                        query.exec(sql);
                        sql=QString("Update ModuleResetStatus set Status=1 Where module=2");
                        query.exec(sql);
                    }else{
                        QMLSignal::I().emitSendResetMsg("0",pos.toInt());

                        if(!resetPosList.contains(pos.toInt())){
                            resetPosList.append(pos.toInt());
                        }
                        if(resetPosList.length()>=6){
                            resetPosList.clear();
                            QSqlDatabase db = dbHelper::openConnection();
                            QSqlQuery query(db);

                            QString sql=QString("Update ModuleResetStatus set Status=1 Where module=4");
                            query.exec(sql);
                        }
                    }
                }
                else {
                    faultAnalysisAndHandling(list,8);
                }
            }
            else if(list[6]=="35"){
                if(list[8]!="02"){
                    faultAnalysisAndHandling(list,8);
                }
                else {
                    QString value=CommonHelper::Common().SixteenToTen(list[9]+" "+list[10]);
                    QMLSignal::I().emitGetHeliumGasPump(value);
                }
            }
            else if(list[6]=="2A"){
                if(list[7]=="21"){
                    QString value=CommonHelper::Common().SixteenToTen(list[8]+" "+list[9]);
                    QMLSignal::I().emitTargetGasPumpValue(value);
                }
                else if(list[7]=="22"){
                    QString value=CommonHelper::Common().SixteenToTen(list[8]+" "+list[9]);
                    QMLSignal::I().emitTargetPadPumpValue(value);
                }
                else if(list[7]=="23"){
                    QString value=CommonHelper::Common().SixteenToTen(list[8]+" "+list[9]);
                    QMLSignal::I().emitTargetAirPumpValue(value);
                }
                else if(list[7]=="24"){
                    QString value=CommonHelper::Common().SixteenToTen(list[8]+" "+list[9]);
                    QMLSignal::I().emitTargetArgonPumpValue(value);
                }
                else if(list[7]=="01"){
                    QString value=list[8]+list[9]+list[10]+list[11];
                    // 转换为32位无符号整数
                    bool ok;
                    uint hexValue = value.toUInt(&ok, 16);

                    // 转换为32位二进制字符串，左侧补零
                    QString binaryStr;
                    for (int i = 31; i >= 0; --i) {
                        binaryStr.append((hexValue & (1 << i)) ? '1' : '0');
                    }
                    QStringList infolist;
                    for (const QChar &ch : binaryStr) {
                        infolist.append(QString(ch)); // 每个字符转为单独的 QString 存入列表
                    }
                    // 直接反转列表
                    std::reverse(infolist.begin(), infolist.end());
                    QMLSignal::I().emitInfolist(infolist);
                }
            }
            else if(list[6]=="39"){
                QString ip=CommonHelper::Common().SixteenToTen(list[8])+"."+CommonHelper::Common().SixteenToTen(list[9])+"."+CommonHelper::Common().SixteenToTen(list[10])+"."+CommonHelper::Common().SixteenToTen(list[11]);
                QString port=CommonHelper::Common().SixteenToTen(list[12]+" "+list[13]);
                QMLSignal::I().emitSendConnectInfo(ip,port);
            }
            else{
                faultAnalysisAndHandling(list,8);

            }
        }
        else if(list[0]=="62" && list[1]=="00" && list[2]=="00" && list[3]=="3D")//接收上传数据
        {
            if(list[6]=="03")//速度数据
            {
                AnimationParseHEX::I().parse(list);
            }
            else if(list[6]=="04"){
                QString statusInfo=list[7]=="00"?"压紧":"松开";
                StaticProperties::purifyingStatus["0"].setValue(statusInfo);

                statusInfo=list[8]=="00"?"压紧":"松开";
                StaticProperties::purifyingStatus["1"].setValue(statusInfo);
            }
            else if(list[6]=="06"){
                QString statusInfo=list[7]=="00"?"有":"无";
                StaticProperties::purifyingStatus["3"].setValue(statusInfo);
            }
            else if(list[6]=="20"){
                analyzeDetectionInformation(list);
            }
        }
    }
}

/**
 * @brief UdpClient::saveLog 保存日志
 * @param type 日志类型
 * @param list 日志信息
 */
void UdpClient::saveLog(QString type,QStringList list)
{
    QString str=list.join(" ");
    if(str.length()>0){
        //接收日志处理
        if(list[0]=="62" && list[1]=="00" && list[2]=="00" && list[3]=="3D")//设备上传数据
        {
            DebugLog::I().customType(QString("%1:\n"+str).arg(type), "LcUploadInfoLog");
        }
        else if(list[0]=="62" && list[1]=="00" && list[2]=="00" && list[3]=="3A" && list[6]=="00")
        {
            DebugLog::I().customType(QString("%1:\n"+str).arg(type), "HeartLog");
        }
        else if(list[0]=="62" && list[1]=="00" && list[2]=="00" && list[3]=="3C" && list[6]=="2A")
        {
            DebugLog::I().customType(QString("%1:\n"+str).arg(type), "AirpumpLog");
        }
        else
        {
            DebugLog::I().customType(QString("%1:\n"+str).arg(type), "CommLog");

            QStringList logList;
            logList.append(CommonHelper::Common().GetTimeStr());
            logList.append(type);
            logList.append(CommCommand::I().translationInstruction(type,list));
            logList.append(str);
            StaticProperties::logInfo.append(logList);

            QMLSignal::I().emitRefCommunicationLog();
        }
    }
}

/**
 * @brief UdpClient::saveReportInfo 保存报告信息
 */
void UdpClient::saveReportInfo()
{
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);

    QString serial;
    QString sql="Select max(Serial) as Serial From ReportInfo";
    query.exec(sql);
    while (query.next()) {
        serial=query.value("Serial").toString().isNull()?"1":query.value("Serial").toString();
    }
    sql=QString("Update ReportInfo Set ExpEndTime='%1' Where Serial='%2'").arg(CommonHelper::Common().GetDateTimeStr(),serial);
    query.exec(sql);

    // 更新实验总时长、半衰期截止日期 [20251119-JNN]
    sql = QString("Select ExpStartTime, ExpEndTime, SampleHalfLife from ReportInfo Where Serial='%1'").arg(serial);
    query.exec(sql);
    QDateTime expStartTime, expEndTime, halfLifeDate;
    QTime sampleHalfLife;
    while(query.next()){
        expStartTime = QDateTime::fromString(query.value("ExpStartTime").toString(), "yyyy-MM-dd hh:mm:ss");
        expEndTime = QDateTime::fromString(query.value("ExpEndTime").toString(), "yyyy-MM-dd hh:mm:ss");
        sampleHalfLife = QTime::fromString(query.value("SampleHalfLife").toString(), "hh:mm:ss");

        int durTime = expStartTime.secsTo(expEndTime);
        sql = QString("Update ReportInfo Set ExpDuration='%1' Where Serial='%2'").arg(QTime(0,0,0).addSecs(durTime).toString("hh时mm分ss秒"),serial);
        query.exec(sql);

        int halfLifeSecs = sampleHalfLife.hour()*3600 + sampleHalfLife.minute()*60 + sampleHalfLife.second();

        halfLifeDate = expEndTime.addSecs(halfLifeSecs * 10);
        sql = QString("Update ReportInfo Set HalfLifeDate='%1' Where Serial='%2'").arg(halfLifeDate.toString("yyyy-MM-dd hh:mm:ss"), serial);
        query.exec(sql);

        break;
    }



    sql="Delete From ExperimentInfo";
    query.exec(sql);

    sql="Delete From ExperimentDetail";
    query.exec(sql);
}

/**
 * @brief UdpClient::IsOnline 是否在线
 * @return 是否超时
 */
bool UdpClient::IsOnline()
{
    return m_bOnLine;
}

/**
 * @brief UdpClient::onTimeout 指令接受超时
 */
void UdpClient::onTimeout(){
    if(!receiveSuccess){
        QMLSignal::I().emitReceiveMsgOutTime();
    }
}

/**
 * @brief UdpClient::faultAnalysisAndHandling 故障解析及处理
 * @param list 故障字符串
 * @param startBit 起始位数
 */
void UdpClient::faultAnalysisAndHandling(QStringList list,int startBit)
{
    if(StaticProperties::expStatus!=0)//实验中
    {
        QString err="故障:";
        QString method;
        QStringList sendErrorList;
        bool needConsolve=false;
        int errType = 0;        // 是并发故障还是流程故障
        for(int i=startBit;i<list.length()-4;i++)
        {
            QString gzdz = list[i];
            sendErrorList.append(gzdz);
            errType = CommonHelper::Common().getErrorType(gzdz);
            if(CommonHelper::Common().isCurrentModuleError(gzdz))
            {
                needConsolve=true;
                QStringList gzdzv=CommonHelper::Common().getErrorInfo(gzdz);
                if(gzdzv.length()>1)
                {
                    if(!gzdzv[0].isNull()&&!gzdzv[0].isEmpty()){
                        err += QString::number(i-6)+"-"+gzdz+" "+gzdzv[0]+"\n";
                    }
                    if(!gzdzv[1].isNull()&&!gzdzv[1].isEmpty()){
                        method += gzdzv[1]+";";
                    }
                }
            }
        }
        if(needConsolve)
        {
            if(err.length()>0){
                QString methodInfo;
                if(method.contains("否")){
                    methodInfo="否";
                }else{
                    methodInfo="是";
                }
                StaticProperties::expLogList[StaticProperties::currentExpModule-1][StaticProperties::expStep]["Status"]="故障";

                QSqlDatabase db = dbHelper::openConnection();
                QSqlQuery query(db);
                QString sql;

                int step=CommonHelper::Common().SixteenToTen(list[6]).toInt();

                if(step==1 &&StaticProperties::isConcurrency)
                {
                    StaticProperties::expConcurrencyLogList[StaticProperties::expUnionStep]["Status"]="故障";
                    sql=QString("Update ReportDetail set status='故障' Where ReportSerial=(Select max(ReportSerial) From ReportDetail) and Step='%1'").arg(QString::number(StaticProperties::expUnionStep));
                    query.exec(sql);


                    // [20251119-JNN] 同一个故障不用发两次
                    //                    QMLSignal::I().emitSendErrorMsg(err,methodInfo,QString::number(StaticProperties::currentExpModule),1);
                }

                StaticProperties::expStatus=3;
                if(StaticProperties::isWait){
                    StaticProperties::isWaitError=true;
                    QMLSignal::I().experimentStatus(5,1,"");
                }
                QMLSignal::I().emitSendErrorMsg(err,methodInfo,QString::number(StaticProperties::currentExpModule), errType);

                QMLSignal::I().emitRefExperimentLog(StaticProperties::currentStep);     // 发信号通知前端
                AnimationParseHEX::I().parseErrorMsg(sendErrorList);
            }
            else
            {
                StaticProperties::expStep=CommonHelper::Common().SixteenToTen(list[6]).toInt()+1;
                ExperimentThread::I().run();
            }
        }
    }
    else//空闲
    {
        QString err;
        QString method="故障:";
        QStringList sendErrorList;
        for(int i=startBit;i<list.length()-4;i++)
        {
            QString gzdz = list[i];
            sendErrorList.append(gzdz);

            QStringList gzdzv=CommonHelper::Common().getErrorInfo(gzdz);
            if(gzdzv.length()>1)
            {
                if(!gzdzv[0].isNull()&&!gzdzv[0].isEmpty()){
                    err += QString::number(i-6)+"-"+gzdz+" "+gzdzv[0]+"\n";
                }
                if(!gzdzv[1].isNull()&&!gzdzv[1].isEmpty()){
                    method += gzdzv[1]+";";
                }
            }
        }

        if(err.length()>0){
            QMLSignal::I().emitSendErrorMsg(err,"确定","0",0);
            AnimationParseHEX::I().parseErrorMsg(sendErrorList);
        }

    }
}

/**
 * @brief UdpClient::analyzeDetectionInformation 解析检测信息
 * @param list 故障信息
 */
void UdpClient::analyzeDetectionInformation(QStringList list){
    int startInt=0;
    if(list[3]=="3A"){
        QString statusInfo=list[14]=="02"?"压紧":"松开";
        if(statusInfo=="压紧"){
            CommonHelper::Common().staticUseTime(5,"1");
        }
        StaticProperties::purifyingStatus["0"].setValue(statusInfo);
        StaticProperties::purifyingStatus["1"].setValue(statusInfo);

        statusInfo=list[15]=="02"?"有":"无";
        StaticProperties::purifyingStatus["2"].setValue(statusInfo);

        statusInfo=list[16]=="02"?"有":"无";
        StaticProperties::purifyingStatus["3"].setValue(statusInfo);

        startInt=17;
    }
    else{
        startInt=7;
    }

    QString statusInfo;

#pragma region "第一字节"{

    QString info = CommonHelper::Common().hexToBinFormatted(list[startInt]);
    QString finalInfo= CommonHelper::Common().binToDecFormatted (info);
    QStringList finalList= finalInfo.split(' ');

    //通道5
    if(CommonHelper::Common().ShieldingDetection(16)){
        StaticProperties::pipeStatus["4"].setValue(4);
    }
    else{
        StaticProperties::pipeStatus["4"].setValue(finalList[0].toInt());
    }

    // 通道4
    if(CommonHelper::Common().ShieldingDetection(15)){
        StaticProperties::pipeStatus["3"].setValue(4);
    }
    else{
        StaticProperties::pipeStatus["3"].setValue(finalList[1].toInt());
    }

    //通道3
    if(CommonHelper::Common().ShieldingDetection(14)){
        StaticProperties::pipeStatus["2"].setValue(4);
    }
    else{
        StaticProperties::pipeStatus["2"].setValue(finalList[2].toInt());
    }

    //通道2
    if(CommonHelper::Common().ShieldingDetection(13)){
        StaticProperties::pipeStatus["1"].setValue(4);
    }
    else{
        StaticProperties::pipeStatus["1"].setValue(finalList[3].toInt());
    }

#pragma endregion}

#pragma region "第二字节"{

    startInt++;

    info = CommonHelper::Common().hexToBinFormatted(list[startInt]);
    finalInfo= CommonHelper::Common().binToDecFormatted (info);
    finalList= finalInfo.split(' ');

    //通道1
    if(CommonHelper::Common().ShieldingDetection(12)){
        StaticProperties::pipeStatus["0"].setValue(4);
    }
    else{
        StaticProperties::pipeStatus["0"].setValue(finalList[0].toInt());
    }

    //吸盘
    statusInfo=getDetectorStatus(finalList[1],0);
    StaticProperties::shiftingTargetStatus["0"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(9);
    }
    //挡板
    statusInfo=getDetectorStatus(finalList[2],0);
    StaticProperties::releasseTargetStatus["2"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(10);
    }

    //夹爪
    statusInfo=getDetectorStatus(finalList[3],0);
    StaticProperties::shiftingTargetStatus["1"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(11);
    }

#pragma endregion}

#pragma region "第三字节"{

    startInt++;

    info = CommonHelper::Common().hexToBinFormatted(list[startInt]);
    finalInfo= CommonHelper::Common().binToDecFormatted (info);
    finalList= finalInfo.split(' ');

    //放靶有无靶材
    statusInfo=getDetectorStatus(finalList[0],1);
    StaticProperties::releasseTargetStatus["0"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(12);
    }

    //放靶气泵
    statusInfo=getDetectorStatus(finalList[1],2);
    StaticProperties::releasseTargetStatus["1"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(13);
    }

    //进料气缸
    statusInfo=getDetectorStatus(finalList[2],0);
    StaticProperties::practiceTargetStatus["3"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(14);
    }

    //送靶气缸
    statusInfo=getDetectorStatus(finalList[3],3);
    StaticProperties::practiceTargetStatus["2"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(15);
    }

#pragma endregion}

#pragma region "第四字节"{

    startInt++;

    //打靶靶材 打靶气泵 靶材盖 水冷机(无)
    info = CommonHelper::Common().hexToBinFormatted(list[startInt]);
    finalInfo= CommonHelper::Common().binToDecFormatted (info);
    finalList= finalInfo.split(' ');

    //打靶有无靶材
    statusInfo=getDetectorStatus(finalList[0],1);
    StaticProperties::practiceTargetStatus["0"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(16);
    }

    //打靶气泵压力
    statusInfo=getDetectorStatus(finalList[1],2);
    StaticProperties::practiceTargetStatus["1"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(17);
    }

    //靶材盖状态
    statusInfo=getDetectorStatus(finalList[2],4);
    StaticProperties::shiftingTargetStatus["2"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(18);
    }

    //水冷机
    statusInfo=getDetectorStatus(finalList[3],4);
    StaticProperties::practiceTargetStatus["4"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(19);
    }

#pragma endregion}

#pragma region "第五字节"{

    startInt++;

    info = CommonHelper::Common().hexToBinFormatted(list[startInt]);
    finalInfo= CommonHelper::Common().binToDecFormatted (info);
    finalList= finalInfo.split(' ');

    //溶靶瓶(无)
    statusInfo=getDetectorStatus(finalList[0],1);
    StaticProperties::shiftingTargetStatus["4"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(20);
    }

    //液位
    if(CommonHelper::Common().ShieldingDetection(11)){
        statusInfo="屏蔽";
    }else{
        if(finalList[1]=="0"){
            statusInfo="空闲";
        }
        else if(finalList[1]=="1"){
            statusInfo="传输完成";
        }
        else if(finalList[1]=="2")
        {
            statusInfo="传输中";
        }
        else if(finalList[1]=="3"){
            statusInfo="故障";
            detectAbnormalReporting(21);
        }
    }
    StaticProperties::shiftingTargetStatus["3"].setValue(statusInfo);

    //靶材片吸取(无)
    statusInfo=getDetectorStatus(finalList[2],5);
    StaticProperties::shiftingTargetStatus["5"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(22);
    }
    //氦气压力
    statusInfo=getDetectorStatus(finalList[3],2);
    StaticProperties::shiftingTargetStatus["7"].setValue(statusInfo);
    if(statusInfo=="故障"){
        detectAbnormalReporting(23);
    }
#pragma endregion}

#pragma region "第六字节"{
    startInt++;

    info = CommonHelper::Common().hexToBinFormatted(list[startInt]);
    finalInfo= CommonHelper::Common().binToDecFormatted (info);
    finalList= finalInfo.split(' ');

    if(finalList.length()>3){
        //送靶气缸
        statusInfo=getDetectorStatus(finalList[0],3);
        StaticProperties::practiceTargetStatus["5"].setValue(statusInfo);
        if(statusInfo=="故障"){
            detectAbnormalReporting(24);
        }
        //打靶有无靶材2
        statusInfo=getDetectorStatus(finalList[1],1);
        StaticProperties::practiceTargetStatus["6"].setValue(statusInfo);
        if(statusInfo=="故障"){
            detectAbnormalReporting(25);
        }
        //靶材罐吸取
        statusInfo=getDetectorStatus(finalList[2],5);
        StaticProperties::practiceTargetStatus["8"].setValue(statusInfo);
        if(statusInfo=="故障"){
            detectAbnormalReporting(26);
        }

        //翻转气缸
        QMLSignal::I().emitPartDetectorStatus(2,finalList[3].toInt());
    }


#pragma endregion}

#pragma region "第七字节"{
    startInt++;
    info = CommonHelper::Common().hexToBinFormatted(list[startInt]);
    QStringList parts = info.split(" ", Qt::SkipEmptyParts);
    // 重组字符串
    QString result = parts[0] + parts[1].left(1) + " " +
            parts[1].mid(1) + parts[2] + " " +
            parts[3];
    finalInfo= CommonHelper::Common().binToDecFormatted (result);
    finalList= finalInfo.split(' ');

    QMLSignal::I().emitPartDetectorStatus(0,finalList[0].toInt());
    QMLSignal::I().emitPartDetectorStatus(1,finalList[1].toInt());

#pragma endregion}

}

/**
 * @brief UdpClient::getDetectorStatus 获取检测状态
 * @param info 检测类型(0 1正常 2故障 3屏蔽)
 * @param type 显示字类型(0正常 1有无 2正常异常 3进料位置 送靶位置 4关闭打开 5吸取未吸取)
 * @return
 */
QString UdpClient::getDetectorStatus(QString info,int type){
    if(info=="0" || info=="1")
    {
        switch (type) {
        case 0:
            return "正常";
        case 1:
            return info=="0"?"无":"有";
        case 2:
            return info=="0"?"正常":"异常";
        case 3:
            return info=="0"?"梭体上靶位置":"送靶位置";
        case 4:
            return info=="0"?"关闭":"打开";
        case 5:
            return info=="0"?"未吸取":"吸取";
        case 6:
            return info=="0"?"水平":"垂直";
        }
    }
    else if(info=="2")
    {
        return "故障";
    }
    else if(info=="3")
    {
        return "屏蔽";
    }
    else
    {
        return "--";
    }
    return "";
}

void UdpClient::exportCpsData(){
    QSharedPointer<QXlsx::Document> pxlsx = (QSharedPointer<QXlsx::Document>)new QXlsx::Document();
    pxlsx->addSheet("能谱数据");
    pxlsx->selectSheet("能谱数据");
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    pxlsx->write("A1","时间");
    pxlsx->write("B1","Counts(cps)");
    QString  sql="Select * From CPSData";
    query.exec(sql);
    int i=2;
    while (query.next())
    {
        pxlsx->write("A"+QString::number(i),query.value("ReadTime").toString());
        pxlsx->write("B"+QString::number(i),query.value("ReadData").toString());
        i++;
    }
    sql="Select Path From ExportInfo";
    query.exec(sql);
    QString path;
    QDateTime current=QDateTime::currentDateTime();
    QString dateStr=current.toString("yyyyMMddhhmmss");
    while (query.next()) {
        path=query.value("Path").toString()+"/"+dateStr+".xlsx";
    }
    pxlsx->saveAs(path);
}

void UdpClient::detectAbnormalReporting(int serial)
{
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QString sql=QString("Select Info,IsBlocked,Module From DetectorInformation Where Serial='%1'").arg(QString::number(serial));
    query.exec(sql);
    while (query.next()) {
        if(query.value("IsBlocked").toString()=="否"){
            QString module=query.value("Module").toString();
            if(module.contains(CommonHelper::Common().getCurrentExpTypeName(StaticProperties::currentExpModule))){
                QString msg=QString("检测:%1检测异常").arg(query.value("Info").toString());
                QMLSignal::I().emitSendErrorMsg(msg,"是",QString::number(StaticProperties::currentExpModule),0);
            }
        }
    }
}
